﻿#include "itemview.h"
#include "ui_itemview.h"

ItemView::ItemView(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ItemView)
{
    ui->setupUi(this);
    defaultSize=this->size();
}

ItemView::~ItemView()
{
    delete ui;
}

void ItemView::display(const QString &detail)
{
    if(detail.isEmpty())
        return;
    this->resize(defaultSize);
    if(detail.startsWith(PRE_IMG))
    {
        QString filePath=detail;
        filePath=filePath.remove(PRE_IMG);
        QPixmap pix(filePath);
        if(pix.isNull())
            return;
        ui->display->setPixmap(pix);
    }
    else
        ui->display->setText(detail);

    if(!this->isVisible())
        this->show();
}
